package com.aiyige.page.publish.selectprice;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.aiyige.R;
import com.aiyige.page.publish.selectprice.model.PriceItem;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.LinkedList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by zhuyakun on 2018/4/8.
 */
public class PriceItemAdapter extends BaseQuickAdapter<PriceItem, PriceItemAdapter.ViewHolder> {
    public PriceItemAdapter() {
        super(R.layout.price_item, new LinkedList<PriceItem>());
    }

    @Override
    protected void convert(ViewHolder helper, PriceItem item) {
        helper.bindData(item);
    }

    public class ViewHolder extends BaseViewHolder {
        @BindView(R.id.priceTv)
        TextView priceTv;
        @BindView(R.id.selectIv)
        ImageView selectIv;
        @BindView(R.id.currencySymbolTv)
        TextView currencySymbolTv;

        public ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

        public void bindData(PriceItem item) {
            priceTv.setText(item.getPriceStr());
            currencySymbolTv.setSelected(item.isSelected());
            priceTv.setSelected(item.isSelected());
            selectIv.setVisibility(item.isSelected() ? View.VISIBLE : View.INVISIBLE);
        }
    }
}
